home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / challenge / 13.09 / ChallengeTuring.sit.hqx / Challenge, Turing / Turing.h < prev    next >
Text File  |  1997-06-19  |  1KB  |  44 lines

  1. // Turing.h
  2. #pragma once
  3.  
  4. #include <Types.h>
  5.  
  6. #ifdef USE_C
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #endif
  11.  
  12. typedef unsigned long ulong;
  13.  
  14. typedef enum {kMoveLeft=-1,kHalt=0, kMoveRight=1} MoveDir;
  15.  
  16. typedef struct TMRule {  /* rule in program for TM */
  17.   ulong oldState;        /* this rule fires when currentState == oldState and */
  18.   ulong inputSymbol;     /*   currentSymbol == inputSymbol */
  19.   ulong newState;        /* set currentState to newState when this rule fires */
  20.   ulong outputSymbol;    /* write outputSymbol to tape when this rule fires */
  21.   MoveDir moveDirection; /* move left or right as indicated when this rule fires */
  22. } TMRule;
  23.  
  24. typedef void (*TMMoveProc) (
  25.   ulong outputSymbol,
  26.   ulong newState,
  27.   MoveDir moveDirection
  28. );
  29.  
  30. Boolean /* success */ TuringMachine(
  31.   const TMRule theRules[],  /* pointer to program for TM */
  32.   ulong numRules,             /* number of rules in TM program */
  33.   ulong *theTape,             /* pointer to input tape for TM */
  34.   ulong tapeLen,              /* theTape[0]..theTape[tapeLen-1] is valid */
  35.   long rwHeadPos,             /* TM read head is at theTape[rwHeadPos] */
  36.   TMMoveProc ReportMove       /* callback proc to inform caller of each move */
  37. );
  38.  
  39. #ifdef USE_C
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif
  44.